-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate messageCreate off sapphire #328
Conversation
import { ApplyOptions } from '@sapphire/decorators'; | ||
import { container, Listener } from '@sapphire/framework'; | ||
import { Message } from 'discord.js'; | ||
import { ILogger } from '@sapphire/framework'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep sapphire dependency for logger
@@ -61,7 +59,7 @@ const punishSpammersAndTrolls = async (message: Message): Promise<boolean> => { | |||
error: (err as Error).toString() | |||
}); | |||
} | |||
await sendKickEmbed(message, user, reason, isSuccessful); | |||
await sendKickEmbed(client, message, user, reason, isSuccessful); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pass in the client as argument rather than using container
if (message.author.bot && message.author.id !== IRC_USER_ID) { | ||
return; | ||
} | ||
export const initMessageCreate = async (client: Client, logger: ILogger, message: Message): Promise<void> => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Convert class to function
@@ -9,8 +8,13 @@ export const EMBED_COLOUR = '#0099ff'; | |||
/* | |||
* Send kick embed | |||
*/ | |||
export const sendKickEmbed = async (message: Message, user: User, reason = '', isSuccessful = true): Promise<void> => { | |||
const { client } = container; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use client argument instead of container
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small nitpick
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a comment about if (client.user)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Summary of Changes
Migrates messageCreate logic to a discord.js based file in src/events.
PRs
Resolves #315
Steps to Reproduce
Behaviour is confirmed to be the same with no regressions.